#!/usr/bin/env python
# -*- coding: utf-8 -*-

#INSERT INTO [digitwhu].[dbo].[building]
#           ([name]
#           ,[type]
#           ,[path_id]
#           ,[district_id]
#           ,[arrange])
#     VALUES
#           (<name, nvarchar(50),>
#           ,<type, nvarchar(50),>
#           ,<path_id, int,>
#           ,<district_id, int,>
#           ,<arrange, int,>)
#GO

header = """
INSERT INTO [digitwhu].[dbo].[building]
           ([name]
          ,[type]
           ,[path_id]
           ,[district_id]
           ,[arrange])
     VALUES
"""

body = ''
f = open('building_info')
content = f.read()
for line in content.split('\n'):
	parts = line.split(' ')
	#文件结尾
	if( len(parts) == 1 ):
		continue
	bName , bType = line.split(' ')
	body += "('{0}','{1}',NULL,NULL,NULL),".format(bName,bType)
#删除结尾逗号
body = body[0:-1]

footer = """
GO
"""

print header + body + footer
